import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'post_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';

class PostView extends GetView{

  PostController controller = Get.put(PostController());

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: BaseAppBar(preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child: const Text('岗位'),),
      body: GetBuilder<PostController>(builder: (_){
        return EasyRefresh.custom(
          slivers: [
            SliverList(delegate: _mySliverChildBuilderDelegate(),)
          ],
        );
      }),
    );
  }

  _mySliverChildBuilderDelegate() {
    return SliverChildBuilderDelegate(
          (BuildContext context, int index) {
        return GestureDetector(
          onTap: (){
            var params = {
              'name':controller.model?.data?[index].name,
              'id':controller.model?.data?[index].id
            };
            Get.back(result:params);
          },
          child: Container(
            margin: EdgeInsets.only(top: 5),
            color: Colors.white,
            padding: EdgeInsets.all(15),
            child: Row(
              children: [
                Text('${controller.model?.data?[index].name}'),

              ],
            ),
          ),
        );
      },
      childCount: controller.model?.data?.length??0,
    );
  }


}